<?php
include_once '../includes/common.php';
if($islogin2==1){}else sysmsg("您还未登录，请先登录",2,'./login.php',true);
if($_SERVER['HTTP_REFERER'] == ""){
    sysmsg("非法请求,注意您的行为！");
    die;
}
if($conf['Market_open']!=1)sysmsg('授权平台未开放商城系统！',2,'./',true);
?>
<?php
$numrows=$DB->count("SELECT count(*) from authguao_shoplog WHERE uid='{$userrow['uid']}'");
?>
<?php
if($numrows==0){
    echo '1';
}else{
$pagesize=12;
$pages=ceil($numrows/$pagesize);
$page=isset($_GET['page'])?intval($_GET['page']):1;
$offset=$pagesize*($page - 1);
$rs=$DB->query("SELECT * FROM authguao_shoplog WHERE uid='{$userrow['uid']}' order by id desc limit $offset,$pagesize");
while($res = $DB->fetch($rs))
{
    $shop = $DB->get_row("select * from authguao_shop where id='" . $res['tid'] . "' limit 1");
    if ($shop['uid'] == 1) {
        if($conf['admin_qq']){
            $qq=$conf['admin_qq'];
        }else{
            $qq=$conf['kfqq'];
        }
        $power = '管理员';
    } else {
        $user = $DB->get_row("select * from authguao_user where uid='" . $shop['uid'] . "' limit 1");
        $qq = $user['qq'];
        $power = '用户';
    }
    $versions = '<a class="layui-btn layui-btn-xs" title="点我查看版本日志" style="background-color:#7B1FA2" href="javascript:layer.alert(\''.$shop['updatelog'].'\',{title:\'商品版本日志\'})">V'.$shop['version'].'</a>';
    $shop_log = $DB->get_row("select * from authguao_shoplog where tid='" . $shop['id'] . "' and uid='" . $userrow['uid'] . "' limit 1");
    if ($res['version'] < $shop['version']) {
        $alt = '<span style="color:red">版本需要升级('.$shop['version'].')</span>';
    } else if ($shop_log) {
        $alt = '已购买';
    } else {
        if ($shop['money'] == '0.00') {
            $alt = '<span style="color:#5FB878">免费获取</span>';
        } else {
            $alt = '<span style="color:#FF5722">立即购买</span>';
        }
    }
    if ($shop['proid'] == 999999999) {
        $system = '<a class="layui-btn layui-btn-xs" style="background-color:#80CBC4">'.$shop['system_name'].'</a>';
    } else {
        $program = $DB->get_row("select * from authguao_program where id='" . $shop['proid'] . "' limit 1");
        $system = '<a class="layui-btn layui-btn-xs" style="background-color:#FF8A80">'.$program['name'].'</a>';
    }
    if ($shop['money'] == '0.00') {
        $money = '<span style="font-size:0.7em;color:#5FB878">免费</span>';
        $moneys = 0;
    } else {
        $money = '<span style="color:#FF5722">'.$shop['money'].'</span>';
        $moneys = $shop['money'] * 7;
    }
    $shopimg = explode(',', $shop['image']);
    echo '<div class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg3 auth_div">
<div class="cmdlist-container">
<div class="layui-card-header layui-elip" style="text-align: center;font-size: 1.4em;" title="'.$shop['name'].'">'.$shop['name'].'</div>
<a href="javascript:;" class="auth_a_image">
<img src="'.$shopimg[0].'" onclick="image_msg('.$shop['id'].')" class="layui-anim layui-anim-fadein auth_image" title="'.$power.qqname($urow['qq']).'投稿" />
</a>
<a href="javascript:;">
<div class="cmdlist-text">
<p class="info" title="'.$shop['name'].'" >'.$shop['name'].'</p>
<div class="price layui-text layui-elip">
<img href="user_details.php?uid='.$shop['uid'].'" title="'.qqname($qq).'的主页" src="http://q1.qlogo.cn/g?b=qq&nk='.$qq.'&s=100&t=1547904810" style="width: 2em;height:2em;margin-bottom: 0.3em;border-radius: 0.3em;" class="layui-anim layui-anim-up" />
<i class="layui-icon layui-icon-username"></i> '.$power.':'.qqname($qq).'投稿<br>
</div>
<div class="price"><b>'.$money.'</b>
<p class="layui-elip" style="width:4em;color:#999" title="'.$moneys.'">¥<del>'.$moneys.'</del> </p>
<span class="flow" title="当前共'.$shop['praise'].'个赞，点个赞？" onclick="praise('.$shop['id'].')" >
<i class="layui-icon layui-icon-praise"></i><span id="praise_'.$shop['id'].'">'.$shop['praise'].'</soan></span>
</div>
<div class="price layui-text-center" style="padding-top: 0.25em;margin-top: 0.25em;border-top: 1px solid #eee;">
<a href="shop_details.php?id='.$shop['id'].'" title="商品'.$shop['name'].'详情页">
<div class="layui-row"><div class="layui-col-xs12"><button class="layui-btn layui-btn-fluid layui-btn-sm layui-btn-primary">'.$alt.'</button></div><div class="auth_biaot" style="text-align:center;padding-top:0.3em">'.$system.'</div><div class="auth_left" style="text-align:center;padding-top:0.5em">'.$versions.'</div></div></div></a>
</div>
</div>
</a>
</div>
</div>';
}
?>
<div class="text-center">
<?php
#分页
$pageList=new Page($numrows,$pagesize,1,$link);
echo $pageList->showPage();
?>
</div>
<?php
}
?>